package com.csxh.util;

public class StringUtil {

	public static boolean isNotNullAndEmpty(String str) {
		
		return null!=str && !"".equals(str);
		
	}
	
	public static boolean isNullOrEmpty(String str) {
		
		return null==str || "".equals(str);
		
	}

	public static String upperCharAt(int index, String input) {
		if (isNullOrEmpty(input) || index<0 || index>=input.length()) {
			return input;
		}
		
		StringBuffer sBuffer=new StringBuffer();
		for(int i=0;i<input.length();i++){			
			char ch=input.charAt(i);
			if (i==index) {				
				ch=Character.toUpperCase(ch);
			}
			sBuffer.append(ch);			
		}
		
		return sBuffer.toString();
	}
	
	public static String lowerCharAt(int index, String input) {
		if (isNullOrEmpty(input) || index<0 || index>=input.length()) {
			return input;
		}
		
		StringBuffer sBuffer=new StringBuffer();
		for(int i=0;i<input.length();i++){			
			char ch=input.charAt(i);
			if (i==index) {				
				ch=Character.toLowerCase(ch);
			}
			sBuffer.append(ch);			
		}
		
		return sBuffer.toString();
	}
}
